#!/sbin/openrc-run

name=pict-rs
description="pict-rs image hosting service"

: ${cfgfile:="/etc/pict-rs/pict-rs.toml"}

command="/usr/bin/pict-rs"
command_args="-c $cfgfile run"
command_background=true
command_user="pict-rs:pict-rs"
pidfile="/run/${RC_SVCNAME}.pid"
directory="/var/lib/pict-rs"
output_log="/var/log/pict-rs.log"
error_log="/var/log/pict-rs.err"

required_files="$cfgfile"

depend() {
	need localmount net
	after firewall
}

start_pre() {
	checkpath -f -m 0640 -o "root:pict-rs" "$cfgfile"
	checkpath -f -m 0640 -o "$command_user" "$output_log" "$error_log"
	checkpath -d -m 0750 -o "$command_user" "$directory"
}
